class DateTimer extends egret.Timer{
  public static TIMER_CHANGE = 'timerChange';
  private dateTime:Date;
  private evt:egret.TimerEvent;

  public constructor(hour:number, minute:number){
    super(150);

    this.dateTime = new Date();
    this.dateTime.setHours(hour, minute);

    this.evt = new egret.TimerEvent(DateTimer.TIMER_CHANGE, false, false);

    this.addEventListener(
      egret.TimerEvent.TIMER, 
      ()=>{        
        this.update(2);
      }, 
      this
    );
  }

  public update(minuteAdd:number){
    var ms = this.dateTime.getTime();
    ms += minuteAdd * 60000;
    this.dateTime.setTime(ms);
    this.dispatchEvent(this.evt);    
  }

  get hour():number {
    return this.dateTime.getHours();
  }

  get minute():number {
    return this.dateTime.getMinutes();
  }
}

class DateTimerUI extends egret.Sprite{
  public constructor(timer:DateTimer){
      super();
      this.createView();
      timer.addEventListener(DateTimer.TIMER_CHANGE, this.timeChange, this);
  }

  public timeChange(evt:egret.TimerEvent){
    this.timeUpdate(evt.target);
  }

  protected timeUpdate(timer:DateTimer){

  }

  protected createView(){

  }

  /**
   * 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。
   * Create a Bitmap object according to name keyword.As for the property of name please refer to the configuration file of resources/resource.json.
   */
  protected createBitmapByName(name: string): egret.Bitmap {
      var result: egret.Bitmap = new egret.Bitmap();
      var texture: egret.Texture = RES.getRes(name);
      result.texture = texture;
      return result;
  }      
}